#-*- coding: utf-8 -*-
import re


class InvalidMarkerException(Exception):
    pass

class ParamUrl(object):
    def __init__(self):
        pass
    
    def toParamUrl(self):
        pass

class MarkerColor(object):
    class _ColorParam(ParamUrl):
        def __init__(self, color):
            self._color = color
            
        def toParamUrl(self):
            return "color:{0}".format(self._color)
    
    BLACK = _ColorParam("black")
    BROWN = _ColorParam("brown")
    GREEN = _ColorParam("green")
    PURPLE = _ColorParam("purple")
    YELLOW = _ColorParam("yellow")
    BLUE = _ColorParam("blue")
    GRAY = _ColorParam("gray")
    ORANGE = _ColorParam("orange")
    RED = _ColorParam("red")
    WHITE = _ColorParam("white")
    

class MarkerSize(object):
    class _SizeParam(ParamUrl):
        def __init__(self, size):
            self._size = size
            
        def toParamUrl(self):
            return "size:{0}".format(self._size)
        
    TINY = _SizeParam("tiny")
    MID = _SizeParam("mid")
    SMALL = _SizeParam("small")
    

class MarkerLabel(object):
    validLabel = re.compile("^[A-Z|0-9]$")
    def __init__(self, label):
        if not self.validLabel.match(label):
            raise InvalidMarkerException("Só é permitido label com um único caractere alfanumérico em caixa alta {A-Z|0-9}")
    
        self._label = label
        
    def toParamUrl(self):
        return "label:{0}".format(self._label)
            


class MarkerUrl(ParamUrl):
    def __init__(self, label="A", size=MarkerSize.MID, color=MarkerColor.BLUE):
        self.color = color
        self.size = size
        self.label = label
        self.locations = []
    
    def addLocationAddress(self, address):
        self.locations.append(address)

    def addLocationPosition(self, latitude, longitude):
        self.locations.append(str(latitude) + "," + str(longitude))

    def toParamUrl(self):
        paramUrl = ""
        return paramUrl
